package com.qf.test2;

import com.qf.entity.Dept;
import com.qf.entity.Emp;
import com.qf.service.DeptService;
import com.qf.service.EmpService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

/**
 * 2019/9/29
 * Administrator
 * springdata0928
 * 面向对象面向君  不负代码不负卿
 */
public class Demo1 {
    public static void main(String[] args) {

        ApplicationContext applicationContext=
                new ClassPathXmlApplicationContext("spring-data.xml");
        DeptService deptService = (DeptService) applicationContext.getBean("deptService");
        //创建雇员对象
        Emp e=new Emp();
        e.setEmpName("张三");
        e.setAge(19);
        UUID uuid = UUID.randomUUID();
        String s = uuid.toString();
        e.setEmpno(s.replace("-", ""));
           //创建部门
        Dept dept=new Dept();
        dept.setDeptName("教学部2");
        //建立部门和雇员的数据关系
        List list=new ArrayList();
        list.add(e);
        dept.setEmps(list);
        e.setDept(dept);
        //调取方法
        Dept dept1 = deptService.insertDept(dept);
        System.out.println(dept1);
    }
}
